package collection;


import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

/**
 * 集合之间的操作
 */
public class CollectionDemo4 {
    public static void main(String[] args) {

        Collection c1 = new ArrayList();
        //Collection c1 = new HashSet();
        c1.add("西红柿");
        c1.add("梨子");
        c1.add("香蕉");
        c1.add("榴莲");

        System.out.println(c1);

        Collection c2 = new ArrayList();
        c2.add("白菜");
        c2.add("土豆");
        c2.add("西红柿");
        System.out.println(c2);

        c1.addAll(c2);
        System.out.println(c1);
        System.out.println(c2);

        Collection c3 = new ArrayList();
        c3.add("梨子");
        c3.add("香蕉");
        c3.add("榴莲");
        //c3.add("西瓜");

        boolean contains = c1.containsAll(c3);
        System.out.println("是否包含所有：" + contains);

        System.out.println("====================================");
        //c1.retainAll(c3);
        System.out.println(c1);
        System.out.println(c3);

        c1.removeAll(c3);
        System.out.println(c1);
        System.out.println(c3);
    }
}
